public class test05 {
    public ListNode removeNthFromEnd(ListNode head, int n) {
        //快慢指针
        ListNode dummy = new ListNode(-1,head);
        ListNode fastNode = dummy;
        ListNode slowNode = dummy;
        for(int i = 0;i<=n;i++){
            fastNode = fastNode.next;
        }
        while(fastNode!=null){
            fastNode = fastNode.next;
            slowNode = slowNode.next;
        }
        slowNode.next = slowNode.next.next;
        return dummy.next;
    }
}
